<?php
include_once 'msg_redirect.php';
include_once 'sql_connect.php';
/*
* Copyright (c) 2008 http://www.webmotionuk.com / http://www.webmotionuk.co.uk
* "PHP & Jquery image upload & crop"
* Date: 2008-11-21
* Ver 1.2
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
* IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 
* THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
error_reporting (E_ALL ^ E_NOTICE);
session_start(); //Do not remove this
//only assign a new timestamp if the session variable is empty
if (!isset($_SESSION['random_key']) || strlen($_SESSION['random_key'])==0){
    $_SESSION['random_key'] = strtotime(date('Y-m-d H:i:s')); //assign the timestamp to the session variable
	$_SESSION['user_file_ext']= "";
}
#########################################################################################################
# CONSTANTS																								#
# You can alter the options below																		#
#########################################################################################################
$upload_dir = "upload_pic"; 				// The directory for the images to be saved in
$upload_path = $upload_dir."/";				// The path to where the image will be saved
$large_image_prefix = "resize_"; 			// The prefix name to large image
$thumb_image_prefix = "thumbnail_";			// The prefix name to the thumb image
$large_image_name = $large_image_prefix.$_SESSION['random_key'];     // New name of the large image (append the timestamp to the filename)
$thumb_image_name = $thumb_image_prefix.$_SESSION['random_key'];     // New name of the thumbnail image (append the timestamp to the filename)
$max_file = "3"; 							// Maximum file size in MB
$max_width = "150";							// Max width allowed for the large image
$big_width = "150";							// 大图宽
$big_height = "150";						// 大图高
$thumb_width = "50";						// Width of thumbnail image
$thumb_height = "50";						// Height of thumbnail image
$small_width = "30";						// 小图宽
$small_height = "30";						// 小图高
// Only one of these image types should be allowed for upload
$allowed_image_types = array('image/pjpeg'=>"jpg",'image/jpeg'=>"jpg",'image/jpg'=>"jpg",'image/png'=>"png",'image/x-png'=>"png",'image/gif'=>"gif");
$allowed_image_ext = array_unique($allowed_image_types); // do not change this
$image_ext = "";	// initialise variable, do not change this.
foreach ($allowed_image_ext as $mime_type => $ext) {
    $image_ext.= strtoupper($ext)." ";
}


##########################################################################################################
# IMAGE FUNCTIONS																						 #
# You do not need to alter these functions																 #
##########################################################################################################
function resizeImage($image,$width,$height,$scale) {
	list($imagewidth, $imageheight, $imageType) = getimagesize($image);
	$imageType = image_type_to_mime_type($imageType);
	$newImageWidth = ceil($width * $scale);
	$newImageHeight = ceil($height * $scale);
	$newImage = imagecreatetruecolor($newImageWidth,$newImageHeight);
	switch($imageType) {
		case "image/gif":
			$source=imagecreatefromgif($image); 
			break;
	    case "image/pjpeg":
		case "image/jpeg":
		case "image/jpg":
			$source=imagecreatefromjpeg($image); 
			break;
	    case "image/png":
		case "image/x-png":
			$source=imagecreatefrompng($image); 
			break;
  	}
	imagecopyresampled($newImage,$source,0,0,0,0,$newImageWidth,$newImageHeight,$width,$height);
	
	switch($imageType) {
		case "image/gif":
	  		imagegif($newImage,$image); 
			break;
      	case "image/pjpeg":
		case "image/jpeg":
		case "image/jpg":
	  		imagejpeg($newImage,$image,90); 
			break;
		case "image/png":
		case "image/x-png":
			imagepng($newImage,$image);  
			break;
    }
	
	chmod($image, 0777);
	return $image;
}
//You do not need to alter these functions
function resizeThumbnailImage($thumb_image_name, $image, $width, $height, $start_width, $start_height, $scale){
	list($imagewidth, $imageheight, $imageType) = getimagesize($image);
	$imageType = image_type_to_mime_type($imageType);
	
	$newImageWidth = ceil($width * $scale);
	$newImageHeight = ceil($height * $scale);
	$newImage = imagecreatetruecolor($newImageWidth,$newImageHeight);
	switch($imageType) {
		case "image/gif":
			$source=imagecreatefromgif($image); 
			break;
	    case "image/pjpeg":
		case "image/jpeg":
		case "image/jpg":
			$source=imagecreatefromjpeg($image); 
			break;
	    case "image/png":
		case "image/x-png":
			$source=imagecreatefrompng($image); 
			break;
  	}
	imagecopyresampled($newImage,$source,0,0,$start_width,$start_height,$newImageWidth,$newImageHeight,$width,$height);
	switch($imageType) {
		case "image/gif":
	  		imagegif($newImage,$thumb_image_name); 
			break;
      	case "image/pjpeg":
		case "image/jpeg":
		case "image/jpg":
	  		imagejpeg($newImage,$thumb_image_name,90); 
			break;
		case "image/png":
		case "image/x-png":
			imagepng($newImage,$thumb_image_name);  
			break;
    }
	chmod($thumb_image_name, 0777);
	return $thumb_image_name;
}
//You do not need to alter these functions
function getHeight($image) {
	$size = getimagesize($image);
	$height = $size[1];
	return $height;
}
//You do not need to alter these functions
function getWidth($image) {
	$size = getimagesize($image);
	$width = $size[0];
	return $width;
}

//Image Locations
$large_image_location = $upload_path.$large_image_name.$_SESSION['user_file_ext'];
$thumb_image_location = $upload_path.$thumb_image_name.$_SESSION['user_file_ext'];

//Create the upload directory with the right permissions if it doesn't exist
if(!is_dir($upload_dir)){
	mkdir($upload_dir, 0777);
	chmod($upload_dir, 0777);
}

//Check to see if any images with the same name already exist
if (file_exists($large_image_location)){
	if(file_exists($thumb_image_location)){
		$thumb_photo_exists = $upload_path.$thumb_image_name.$_SESSION['user_file_ext'];
	}else{
		$thumb_photo_exists = "";
	}
   	$large_photo_exists = $upload_path.$large_image_name.$_SESSION['user_file_ext'];
} else {
   	$large_photo_exists = "";
	$thumb_photo_exists = "";
}

if (isset($_POST["upload"])) { 
	//Get the file information
	$userfile_name = $_FILES['image']['name'];
	$userfile_tmp = $_FILES['image']['tmp_name'];
	$userfile_size = $_FILES['image']['size'];
	$userfile_type = $_FILES['image']['type'];
	$filename = basename($_FILES['image']['name']);
	$file_ext = strtolower(substr($filename, strrpos($filename, '.') + 1));
	
	//Only process if the file is a JPG, PNG or GIF and below the allowed limit
	if((!empty($_FILES["image"])) && ($_FILES['image']['error'] == 0)) {
		
		foreach ($allowed_image_types as $mime_type => $ext) {
			//loop through the specified image types and if they match the extension then break out
			//everything is ok so go and check file size
			if($file_ext==$ext && $userfile_type==$mime_type){
				$error = "";
				break;
			}else{
				$error = "Only <strong>".$image_ext."</strong> images accepted for upload<br />";
			}
		}
		//check if the file size is above the allowed limit
		if ($userfile_size > ($max_file*1048576)) {
			$error.= "Images must be under ".$max_file."MB in size";
		}
		
	}else{
		$error= "Select an image for upload";
	}
	//Everything is ok, so we can upload the image.
	if (strlen($error)==0){
		
		if (isset($_FILES['image']['name'])){
			//this file could now has an unknown file extension (we hope it's one of the ones set above!)
			$large_image_location = $large_image_location.".".$file_ext;
			$thumb_image_location = $thumb_image_location.".".$file_ext;
			
			//put the file ext in the session so we know what file to look for once its uploaded
			$_SESSION['user_file_ext']=".".$file_ext;
			
			move_uploaded_file($userfile_tmp, $large_image_location);
			chmod($large_image_location, 0777);
			
			$width = getWidth($large_image_location);
			$height = getHeight($large_image_location);
			//Scale the image if it is greater than the width set above
			if ($width > $max_width){
				$scale = $max_width/$width;
				$uploaded = resizeImage($large_image_location,$width,$height,$scale);
			}else{
				$scale = 1;
				$uploaded = resizeImage($large_image_location,$width,$height,$scale);
			}
			//Delete the thumbnail file so the user can create a new one
			if (file_exists($thumb_image_location)) {
				unlink($thumb_image_location);
			}
		}
		//Refresh the page to show the new uploaded image
		header("location:".$_SERVER["PHP_SELF"]);
		exit();
	}
}

if (isset($_POST["upload_thumbnail"]) && strlen($large_photo_exists)>0) {
	//Get the new coordinates to crop the image.
	$x1 = $_POST["x1"];
	$y1 = $_POST["y1"];
	$x2 = $_POST["x2"];
	$y2 = $_POST["y2"];
	$w = $_POST["w"];
	$h = $_POST["h"];
	//Scale the image to the thumb_width set above
	$scale = $big_width/$w;
	$cropped = resizeThumbnailImage($thumb_image_location, $large_image_location,$w,$h,$x1,$y1,$scale);
	//Reload the page again to view the thumbnail
	header("location:".$_SERVER["PHP_SELF"]);
	exit();
}

/*删掉已上传图片*/
if ($_GET['a']=="delete" && strlen($_GET['t'])>0){
//get the file locations 
	$large_image_location = $upload_path.$large_image_prefix.$_GET['t'];
	$thumb_image_location = $upload_path.$thumb_image_prefix.$_GET['t'];
	if (file_exists($large_image_location)) {
		unlink($large_image_location);
	}
	if (file_exists($thumb_image_location)) {
		unlink($thumb_image_location);
	}
	header("location:".$_SERVER["PHP_SELF"]);
	exit(); 
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Home | 深大人的微型博客</title>
<link href="css/account.css" rel="stylesheet" type="text/css" />
<!--[if IE 6]>
<link rel="stylesheet" type="text/css" href="iecss.css" />
<![endif]-->
<script type="text/javascript" src="js/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="js/home.js"></script>
<script type="text/javascript" src="js/jquery-pack.js"></script>
<script type="text/javascript" src="js/jquery.imgareaselect.min.js"></script>

<script type="text/javascript">	
$(function(){
var $div_li =$("ul.left_menu li");
$div_li.click(function(){
		$(this).addClass("selected")            //当前<li>元素高亮
		.siblings().removeClass("selected");  //去掉其它同辈<li>元素的高亮
	}).hover(function(){
		$(this).addClass("hover");
		},function(){
	$(this).removeClass("hover");
});

	/*保存按钮改变样式*/
	$(".photo_button1").mouseover(function(){
		$(".photo_button1").attr("src","button/photo_save.png");
		});
	$(".photo_button1").mouseout(function(){
		$(".photo_button1").attr("src","button/photo_save1.png");
		});
	
	/*取消按钮改变样式*/
	$(".photo_button2").mouseover(function(){
		$(".photo_button2").attr("src","button/photo_return.png");
		});
	$(".photo_button2").mouseout(function(){
		$(".photo_button2").attr("src","button/photo_return1.png");
		});
	
	/*传照片按钮改变样式*/
	$("#photo_button").mouseover(function(){
		$("#photo_button").attr("src","button/photo_update.png");
		});
	$("#photo_button").mouseout(function(){
		$("#photo_button").attr("src","button/photo_update1.png");
		});
	/****************/
	
})
</script>
</head>
<body onload="startdate(),startTime()">

<?php
include_once 'msg_redirect.php';	/*通过使用cookie，当检查出未登陆，则不予进入home.php，返回index.php*/
if($_COOKIE['TTU'] != "logined"){
	msg_redirect("您还未登录哦！", "index.php");
}?>
<?php
//Only display the javacript if an image has been uploaded
if(strlen($large_photo_exists)>0){
	$current_large_image_width = getWidth($large_image_location);
	$current_large_image_height = getHeight($large_image_location);?>
<script type="text/javascript">
function preview(img, selection) { 
	var scaleX = <?php echo $big_width;?> / selection.width; 
	var scaleY = <?php echo $big_height;?> / selection.height;
	var scaleX1 = <?php echo $thumb_width;?> / selection.width;
	var scaleY1 = <?php echo $thumb_height;?> / selection.height;
	var scaleX2 = <?php echo $small_width;?>  / selection.width;
	var scaleY2 = <?php echo $small_height;?> / selection.height;
	
	$('#big_head').css({ 
		width: Math.round(scaleX * <?php echo $current_large_image_width;?>) + 'px', 
		height: Math.round(scaleY * <?php echo $current_large_image_height;?>) + 'px',
		marginLeft: '-' + Math.round(scaleX * selection.x1) + 'px', 
		marginTop: '-' + Math.round(scaleY * selection.y1) + 'px' 
	});
	$('#middle_head').css({ 
		width: Math.round(scaleX1 * <?php echo $current_large_image_width;?>) + 'px', 
		height: Math.round(scaleY1 * <?php echo $current_large_image_height;?>) + 'px',
		marginLeft: '-' + Math.round(scaleX1 * selection.x1) + 'px', 
		marginTop: '-' + Math.round(scaleY1 * selection.y1) + 'px' 
	});
	$('#small_head').css({ 
		width: Math.round(scaleX2 * <?php echo $current_large_image_width;?>) + 'px', 
		height: Math.round(scaleY2 * <?php echo $current_large_image_height;?>) + 'px',
		marginLeft: '-' + Math.round(scaleX2 * selection.x1) + 'px', 
		marginTop: '-' + Math.round(scaleY2 * selection.y1) + 'px' 
	});
	$('#x1').val(selection.x1);
	$('#y1').val(selection.y1);
	$('#x2').val(selection.x2);
	$('#y2').val(selection.y2);
	$('#w').val(selection.width);
	$('#h').val(selection.height);
}


$(document).ready(function () { 
	$('#save_thumb').click(function() {
		var x1 = $('#x1').val();
		var y1 = $('#y1').val();
		var x2 = $('#x2').val();
		var y2 = $('#y2').val();
		var w = $('#w').val();
		var h = $('#h').val();
		if(x1=="" || y1=="" || x2=="" || y2=="" || w=="" || h==""){
			alert("You must make a selection first");
			return false;
		}else{
			return true;
		}	
	});
});
$(window).load(function () { 
	$('#thumbnail').imgAreaSelect({ aspectRatio: '1:<?php echo $big_height/$big_width;?>', onSelectChange: preview });
});

</script>
<?php }?>
<div id="main_container">

	<div id="header" >

       <div class="top_right">
       
            <div class="weather">
              <div class="weather_text" id="date"></div>
              <div class="weather_text" id="time"></div>
              <div class="weather_img">
              <a href="#"><img src="image/w_cloudy.png" border="0" width="60" height="60"/></a></div>
            </div>
            
            <div class="big_banner">
            <a href="#"><img src="image/life.jpg" border="0" width="180" height="100"/></a>
            <a href="#"><img src="image/love.jpg"  border="0" width="180" height="100"/></a>
            <a href="#"><img src="image/reading.jpg" border="0" width="180" height="100"/></a>
         </div>
        
        </div>
    
  
        <div id="logo">
            <a href="index.html"><img src="image/logo.png" alt="" title="" border="0" width="240" height="125" /></a>
	    </div>
        

        

    </div>
    
   <div id="main_content"> 
   
            <div id="menu_tab">
                    <ul id="menu">
                    	<li><a href="home.php">首 页</a></li>
                        <li><a href="#">热 门  <img src="image/more.png" /></a>
                         	<ul>
        						<li><a href="hotpeople.php">微博达人</a></li>
        						<li><a href="hotweibo.php">热门微博</a></li>
      						</ul>
                      </li>
                         <li><a href="#">应 用 <img src="image/more.png" /></a>
                         	<ul>
        						<li><a href="photo.php">相册</a></li>
        						<li><a href="collection.php">收藏</a></li>
                                <li><a href="find.php">找人</a></li>
        						<li><a href="#">我的课表</a></li>
        						<li><a href="#">公文通</a></li>
      						</ul>
                         </li>                                                   
                         <li><a href="my_weibo.php">我的主页</a></li>

                         <li><a href="#">消 息  <img src="image/more.png" /></a>
                         	<ul>
        						<li><a href="comment.php">查看评论</a></li>
        						<li><a href="cencerns_from.php">查看粉丝</a></li>
        						<li><a href="my_concerns.php">查看关注</a></li>
      						</ul>
                         </li>                     
                         <li><a href="#">帐 号  <img src="image/more.png" /></a>
                         	<ul>
        						<li><a href="account_info">帐号设置</a></li>
        						<li><a href="logout.php">注销</a></li>
      						</ul>
                         </li>
                         
                    </ul>

            </div><!-- end of menu tab -->
            
    
    <div class="left_content">
     <div class="title_box">帐号设置</div>
     	<ul class="left_menu">
     	<li><a href="account_info">个人信息</a></li>
        <span class="border_m"></span>
        <li class="selected"><a href="upload_head">修改头像</a></li>
        <span class="border_m"></span>
        <li><a href="account_password">修改密码</a></li>
        </ul>  
        
    
   </div><!-- end of left content --> 



   <div class="center_content">
	  <div class="center_title">修改头像</div>
      <span class="border_c"></span>
      <?php
		//Display error message if there are any
		if(strlen($error)>0){
			echo "<ul><li><strong>Error!</strong></li><li>".$error."</li></ul>";
		}
		
		/*如果已经上传照片且已经生产小头像*/
		if(strlen($large_photo_exists)>0 && strlen($thumb_photo_exists)>0){
			/*上传头像*/
			$u_no = $_COOKIE['u_no'];
			$head_sql = mysql_query("select * from head where u_no='$u_no'",$connection);
			$head_result = mysql_fetch_array($head_sql);
	
			/*查看该用户是否已有头像*/
			/*若不曾上传头像*/
			if(!$head_result){
				$my_sql = mysql_query("select MAX(h_id) from head",$connection); /*检查head表中得最大id编号*/
				$my_result = mysql_fetch_array($my_sql);

				/*对将要输入head表的数据项量进行赋值*/
				$h_id = $my_result[0] + 1;

				/*插入数据*/
				mysql_query("insert into head values('$h_id','$thumb_photo_exists','$large_photo_exists','$u_no')",$connection);
				msg("头像保存成功！");
			}
			/*已有头像*/
			else {
				/*更新数据*/
				mysql_query("UPDATE head SET h_data='$thumb_photo_exists',h_data_origin='$large_photo_exists' WHERE u_no='$u_no'");
				msg("头像更新成功！");
			}
			
			
			//Clear the time stamp session and user file extension
			$_SESSION['random_key']= "";
			$_SESSION['user_file_ext']= "";
			?>
			<h2>上传图片</h2>
			<form name="photo" enctype="multipart/form-data" action="<?php echo $_SERVER["PHP_SELF"];?>" method="post">				
				<input type="image" id="photo_button" src="button/photo_update1.png" name="upload" value="Upload" />
                <input type="file" name="image" size="30" class="file"/> 
			</form>
			<p>仅支持JPG,PNG,GIF,图片文件,文件小于3M</p>
      		<div class="photo_box">
      			<div id="photo"><img src="image/photo.png" width="300" height="300"/></div>      
      			<div class="divide"><HR align=center width=1 size=280></div>
     			<div class="img_box">
      				<div class="big_img_box">      
      					<div class="big_img"><img src="<?php 
							/*用以输出用户端的头像*/
							include_once 'sql_connect.php'; 
    						include_once 'msg_redirect.php';
    						$u_no = $_COOKIE['u_no'];
    						$show_head_sql = mysql_query("select h_data from head where u_no='$u_no'",$connection);
    						$show_head_result = mysql_fetch_array($show_head_sql);
    						$my_data = $show_head_result[h_data];
    						if (!$my_data){
    							echo "head_image/09.jpg";
    						}
    						else echo "$my_data";
    						?>"width="150" height="150"/></div>
        				<div class="img_tips">大尺寸头像,150X150像素</div>
        			</div>
                    <div class="middle_img_box">
        				<div class="middle_img"><img src="<?php 
							/*用以输出用户端的头像*/
							include_once 'sql_connect.php'; 
    						include_once 'msg_redirect.php';
    						$u_no = $_COOKIE['u_no'];
    						$show_head_sql = mysql_query("select h_data from head where u_no='$u_no'",$connection);
    						$show_head_result = mysql_fetch_array($show_head_sql);
    						$my_data = $show_head_result[h_data];
    						if (!$my_data){
    							echo "head_image/09.jpg";
    						}
    						else echo "$my_data";
    						?>" width="50" height="50"/></div>
        				<div class="img_tips">中尺寸头像<br />50X50像素</div>
        			</div>
        			<div class="small_img_box">
        				<div class="small_img"><img src="<?php 
							/*用以输出用户端的头像*/
							include_once 'sql_connect.php'; 
    						include_once 'msg_redirect.php';
    						$u_no = $_COOKIE['u_no'];
    						$show_head_sql = mysql_query("select h_data from head where u_no='$u_no'",$connection);
    						$show_head_result = mysql_fetch_array($show_head_sql);
    						$my_data = $show_head_result[h_data];
    						if (!$my_data){
    							echo "head_image/09.jpg";
    						}
    						else echo "$my_data";
    						?>" width="30" height="30"/></div>
        				<div class="img_tips">大尺寸头像<br />30X30像素</div>
        			</div>
      			</div>
      		</div>
      	
			<?php 	
			
		}else{
			
			/*如果已经上传图片*/
			if(strlen($large_photo_exists)>0){?>
				<h2>上传图片</h2>
				<form name="photo" enctype="multipart/form-data" action="<?php echo $_SERVER["PHP_SELF"];?>" method="post">					 
					<input type="image" id="photo_button" src="button/photo_update1.png" name="upload" value="Upload" />
			      <input type="file" name="image2" size="30" class="file"/>
				</form>
				<p>仅支持JPG,PNG,GIF,图片文件,文件小于3M</p>
      			<div class="photo_box">
      				<div id="photo"><img src="<?php echo $upload_path.$large_image_name.$_SESSION['user_file_ext'];?>" id="thumbnail" alt="Create Thumbnail"/></div>      
      				<div class="divide"><HR align=center width=1 size=280></div>
     				<div class="img_box">
      					<div class="big_img_box">      
      						<div class="big_img">
								<div style="border:1px #e5e5e5 solid; float:left; position:relative; overflow:hidden; width:<?php echo $big_width;?>px; height:<?php echo $big_height;?>px;">
									<img src="<?php echo $upload_path.$large_image_name.$_SESSION['user_file_ext'];?>" id="big_head"style="position: relative;" alt="Thumbnail Preview" />
								</div>
							</div>
        					<div class="img_tips">大尺寸头像,150X150像素</div>
        				</div>
                        <div class="middle_img_box">      
      						<div class="middle_img">
								<div style="border:1px #e5e5e5 solid; float:left; position:relative; overflow:hidden; width:<?php echo $thumb_width;?>px; height:<?php echo $thumb_height;?>px;">
									<img src="<?php echo $upload_path.$large_image_name.$_SESSION['user_file_ext'];?>" id="middle_head"style="position: relative;" alt="Thumbnail Preview" />
								</div>
							</div>
        					<div class="img_tips">中尺寸头像50X50像素</div>
        				</div>
                        <div class="small_img_box">      
      						<div class="small_img">
								<div style="border:1px #e5e5e5 solid; float:left; position:relative; overflow:hidden; width:<?php echo $small_width;?>px; height:<?php echo $small_height;?>px;">
									<img src="<?php echo $upload_path.$large_image_name.$_SESSION['user_file_ext'];?>" id="small_head"style="position: relative;" alt="Thumbnail Preview" />
								</div>
							</div>
        					<div class="img_tips">小尺寸头像30X30像素</div>
        				</div> 
      				</div>   
      			</div>
      			<br style="clear:both;"/>
      			<form name="thumbnail" action="<?php echo $_SERVER["PHP_SELF"];?>" method="post">
					<input type="hidden" name="x1" value="" id="x1" />
					<input type="hidden" name="y1" value="" id="y1" />
					<input type="hidden" name="x2" value="" id="x2" />
					<input type="hidden" name="y2" value="" id="y2" />
					<input type="hidden" name="w" value="" id="w" />
					<input type="hidden" name="h" value="" id="h" />
					<input type="image" src="button/photo_save1.png" name="upload_thumbnail" value="保存头像" id="save_thumb" class="photo_button1"/>
                    <input type="image" src="button/photo_return1.png" name="" value="" id="return_button" class="photo_button2"/>
				</form>

		<?php 	
			}
			
			/*若未上传图片*/
			else { 
		?>
		<h2>上传图片</h2>
		<form name="photo" enctype="multipart/form-data" action="<?php echo $_SERVER["PHP_SELF"];?>" method="post">			
			<input type="image" id="photo_button" src="button/photo_update1.png" name="upload" value="Upload" />
            <input type="file" name="image" size="30" class="file"/> 
		</form>
		<p>仅支持JPG,PNG,GIF,图片文件,文件小于3M</p>
      	<div class="photo_box">
      		<div id="photo"><img src="image/photo.png" width="300" height="300"/></div>      
      		<div class="divide"><HR align=center width=1 size=280></div>
     		<div class="img_box">
      			<div class="big_img_box">      
      				<div class="big_img"><img src="<?php 
							/*用以输出用户端的头像*/
							include_once 'sql_connect.php'; 
    						include_once 'msg_redirect.php';
    						$u_no = $_COOKIE['u_no'];
    						$show_head_sql = mysql_query("select h_data from head where u_no='$u_no'",$connection);
    						$show_head_result = mysql_fetch_array($show_head_sql);
    						$my_data = $show_head_result[h_data];
    						if (!$my_data){
    							echo "head_image/09.jpg";
    						}
    						else echo "$my_data";
    						?>" width="150" height="150"/></div>
        			<div class="img_tips">大尺寸头像,150X150像素</div>
        		</div>
                <div class="middle_img_box">
        				<div class="middle_img"><img src="<?php 
							/*用以输出用户端的头像*/
							include_once 'sql_connect.php'; 
    						include_once 'msg_redirect.php';
    						$u_no = $_COOKIE['u_no'];
    						$show_head_sql = mysql_query("select h_data from head where u_no='$u_no'",$connection);
    						$show_head_result = mysql_fetch_array($show_head_sql);
    						$my_data = $show_head_result[h_data];
    						if (!$my_data){
    							echo "head_image/09.jpg";
    						}
    						else echo "$my_data";
    						?>" width="50" height="50"/></div>
        				<div class="img_tips">中尺寸头像<br />50X50像素</div>
        			</div>
        			<div class="small_img_box">
        				<div class="small_img"><img src="<?php 
							/*用以输出用户端的头像*/
							include_once 'sql_connect.php'; 
    						include_once 'msg_redirect.php';
    						$u_no = $_COOKIE['u_no'];
    						$show_head_sql = mysql_query("select h_data from head where u_no='$u_no'",$connection);
    						$show_head_result = mysql_fetch_array($show_head_sql);
    						$my_data = $show_head_result[h_data];
    						if (!$my_data){
    							echo "head_image/09.jpg";
    						}
    						else echo "$my_data";
    						?>" width="30" height="30"/></div>
        				<div class="img_tips">大尺寸头像<br />30X30像素</div>
        			</div>
      		</div>
      	</div>
	<?php }} ?>
   </div><!-- end of center content -->



 
   </div><!-- end of main content -->
   
   
   
   <div class="footer">深圳大学计算机与软件学院@毕业设计项目网站<br />指导老师：王华明<br />项目负责：陈作鑫<br />
    小组成员：陈作鑫&nbsp;&nbsp;陈志杰&nbsp;&nbsp;赖晓东
  </div>                 


</div>
<!-- end of main_container -->
</body>
</html>